"""
__project__ = 'thc'
__file_name__ = 'alert1'
__author__ = 'thc'
__time__ = '2020/12/23/023 16:21'
__product_name = PyCharm
-*- coding:utf-8 -*-
"""

from selenium import webdriver
import os
import time

driver = webdriver.Chrome()
path = os.path.dirname(os.path.abspath(__file__))
file_path = 'file:///' + path + '/alert1.html'
driver.get(file_path)
# prompt
driver.find_element_by_xpath('//div/input[1]').click()
pro = driver.switch_to.alert
print(pro.text)
pro.send_keys('1')
time.sleep(2)
pro.accept()
time.sleep(2)
print(driver.find_element_by_xpath('//span[@id="textSpan"]/font').text)

driver.find_element_by_xpath('//div/input[2]').click()
con = driver.switch_to.alert
print(con.text)
time.sleep(2)
con.accept()
time.sleep(2)

driver.find_element_by_xpath('//div/input[3]').click()
con = driver.switch_to.alert
print(con.text)
time.sleep(2)
con.dismiss()
time.sleep(2)
print(driver.find_element_by_xpath('//span[@id="textSpan"]/font').text)
time.sleep(2)
driver.quit()














